package mementoPattern;

public class Client {

    public static void main(String[] args) {
        History history = new History(); // 管理器

        Editor editor = new Editor("文本1");
        history.push(editor.createMemento());

        editor.setContext("文本2");
        history.push(editor.createMemento());

        editor.setContext("文本3");
        System.out.println("当前内容：" + editor.getContext());

        while (history.hasNext()) {
            editor.restoreMemento(history.pop());
            System.out.println("restore last context："+ editor.getContext());
        }
    }
}
